package cn.com.jtang.wedding.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.jtang.wedding.dao.ChargeDao;
import cn.com.jtang.wedding.model.Charge;

public class ChargeDaoImpl extends BaseDaoImpl implements ChargeDao {
	private static final String ID = "id";
	private static final String CHARGENAME = "chargeName";
	private static final String PRICE = "price";
	private static final String DESCRIPTION = "description";
	
	@Override
	public List insertModelToList(Object object) {
		Charge charge = (Charge)object;
		List args = new ArrayList();
		args.add(0);
		args.add(charge.getChargeName());	
		args.add(charge.getPrice());
		args.add(charge.getDescription());
		return args;
	}

	@Override
	public Object resultMapper(ResultSet rs, int rowNum) throws SQLException {
		Charge charge = new Charge();
		charge.setId(rs.getLong(ID));
		charge.setChargeName(rs.getString(CHARGENAME));
		charge.setPrice(rs.getString(PRICE));
		charge.setDescription(rs.getString(DESCRIPTION));
		return charge;
	}

	@Override
	public Map updateModelToMap(Object object) {
		Charge charge = (Charge)object;
		Map map = new HashMap();
		map.put(ID, charge.getId());
		map.put(CHARGENAME, charge.getChargeName());
		map.put(PRICE, charge.getPrice());
		map.put(DESCRIPTION, charge.getDescription());
		return map;
	}
	

	public String insert(Charge charge){
		return super.insert(charge);
	}
	
	public Charge queryById(Long id){
		return (Charge)super.queryById(id);
	}
	
	public int updateById(Long id, Charge charge) {
		return super.updateById(id, charge);
	}
	
	public int deleteById(Long id) {
		return super.deleteById(id);
	}
	
	public List queryAll(Map<String, Object> map, int start,int end, String... orderByStr){
		return super.queryAll(map, start, end, orderByStr);
	}

}
